﻿//
// Created by Xinjian Chen on 3/22/23.
//

#ifndef MIDDLEWARE_DDS_WRITER_H
#define MIDDLEWARE_DDS_WRITER_H


#include "DeviceWriter.h"
#include "DDSBridge.h"

class DDSContext;

class DDSLocal;

class DDS_Writer : public DeviceWriter {
public:
    /**
     * 新建DDS_Writer
     *
     * @param topicName DDS主题名
     * @param typeName 所使用IDL的类型名
     * @param domainId 通信域ID，未提供时则使用IAppDelegate.h中的device_config::domainId
     */
    DDS_Writer(std::string topicName, std::string typeName = "DataFormat", ZY_DomainId_t domainId = -1);

    ~DDS_Writer();

    int64_t onWrite(char *buffer, int64_t len) override;

    void setupConnection() override;

    void stop() override;

private:
    friend class DDSContext;

    std::string topicName;
    std::string typeName;
    ZY_DomainId_t domainId;
    DDSLocal *local;
};


#endif //MIDDLEWARE_DDS_WRITER_H
